/*
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 *
 * This file is part of Harmattan SmashMiner OpenGL game application.
 * 
 * Harmattan SmashMiner OpenGL Example Application version 1.0.0
 *  
 * Latest update: 15.4.2011
 *
 * The Harmattan SmashMiner OpenGL example application demonstrates how to use 
 * the OpenGL ES in Harmattan devices.
 *
 * This example is provided as a starting point for 3rd party
 * developers (you) to ease the implementation of OpenGL based 
 * games. Ideas, parts of code or methodologies that this
 * example application uses can be freely used without restrictions.
 *
 * See file README.txt how to build and compile this example application
 * in the Harmattan SDK environment. 
 * 
 * See file INSTALL.txt to find out what is required to run this
 * application and how to install the application to the device or
 * alternatively in QEMU-emulator.
 *
 * The LICENSE.txt file explains the license this software is provided
 * with. A copy of the same license is included in this source file.
 * 
 */

/*
 * Copyright (C) 2011 by Nokia Corporation.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#ifndef GAMELEVEL_H
#define GAMELEVEL_H

#include "defines.h"

#include <QObject>

/// \file gamelevel.h

class GameEngine;


/*! \struct GameLevelData
 * For storing level data for current game level.
 */
struct GameLevelData {

    /// Maximum amount of objects in screen at once
    int maxObjectsInScreen;

    /// Amount of asteroids in level
    int asteroids;
    /// Start speed for large asteroid 
    FPtype asteroidSpeedLarge;
    /// Start speed for medium sized asteroid
    FPtype asteroidSpeedMedium;

    /// Amount of UFOs in level
    int ufos;
    /// Missile speed (the speed how fast missiles move towards the miner)
    FPtype missileSpeed;
    /// Missile incidence factor (how rapidly UFO shoot missiles, values from 0.0 ... 0.25 preferred)
    FPtype missileIncidence;
    /// Missile guidance factor (how steep is the missile guidance towards the miner, values from 0.0 ... 0.5 preferred)
    FPtype missileGuidance; 

    /// Amount of meteor showers in level
    int meteorShowers;
    /// The size of meteor showers in level
    int meteorShowerSize;
    /// The speed for meteor showers in level
    FPtype meteorShowerSpeed;
    /// The radius change for meteor showers in level (max-value is 1.0 to prevent gaps from arriving) \sa MeteorShower::radiusChange 
    FPtype meteorShowerRadiusChange;

    /// Amount of black holes in level
    int blackholes;
    /// The speed of black holes in level
    FPtype blackholeSpeed;
    /// The radius of black holes in level (min-value is 15.0 for efficient swallowing effect)
    FPtype blackholeRadius;

    /// Amount of comets in level
    int comets;
    /// The speed for comets in level
    FPtype cometSpeed;
    /// The length change for comets in level (max-value is 20.0) \sa Comet::lengthChange
    FPtype cometLengthChange;
    /// The width of comets in level \sa Comet::startWidth
    FPtype cometWidth;
    /// The width change for comets in level \sa Comet::widthChange
    FPtype cometWidthChange;

    /// Amount of bombs available in level
    int bombs;
    /// Amount of hyper jumps in level
    int hyperjumps;
};

class GameLevel : public QObject
{
    Q_OBJECT

public:

    explicit GameLevel(int, QObject *parent = 0);

    /*! Current level number
     * \return Current level number 
     */
    inline int currentLevel() const { return levelNumber; }
    /*! Sets the current level 
     * \param level Level number 
     */
    inline void setCurrentLevel(int level) { levelNumber = level; }
    void nextLevel(GameLevelData &, int *);

private:

    void newRound();
    void createData();
    void scaleDifficulty(int);

private:

    int levelNumber;
    FPtype difficulty;      // the highest difficulty value is 1.0

    GameLevelData data;
};

#endif // GAMELEVEL_H
